<?php

/**
 * PasswordAnswer form.
 *
 * @package    myarticles
 * @subpackage form
 * @author     Apul Gupta<apulmca2k4@gmail.com>
 */
class PasswordAnswerForm extends BasePasswordAnswerForm
{
  public function configure()
  {
      if(!$this->getOption('isForgot', false))
      {
          if($this->getOption('isFront'))
          {
            unset($this['is_active'], $this['created_at'], $this['updated_at']);
            $this->widgetSchema['user_id'] = new sfWidgetFormInputHidden();
            $this->setDefault('user_id', $this->getOption('user_id'));
          }

          $this->widgetSchema['question_id']->setOption('peer_method','doSelectTop'.$this->getOption('name'));
          $this->validatorSchema['answer']->setOption('required', true);
          $this->validatorSchema['question_id']->setOption('required', true);
      }
      else
      {
           unset($this['is_active'], $this['created_at'], $this['updated_at']);
           $this->widgetSchema['user_id'] = new sfWidgetFormInputHidden();
           $this->widgetSchema['question_id'] = new sfWidgetFormInputHidden();

           $this->widgetSchema['answer'] = new sfWidgetFormInputText(array('label' => $this->getObject()->getQuestion()));
           $this->validatorSchema['answer']->setOption('required', true);
      }
      if($this->getOption('name'))
      {
          $this->widgetSchema->setNameFormat($this->getOption('name').'[%s]');
      }
  }
}